# coding:utf-8
#3.8全部练习题
import random

year_list=[1996,1997,1998,1999,2000,2001]
things=['mzzarellao','cinderrella','salmonella',]
year_list.sort(reverse=True)
for i in range(len(things)):
    print(things[i].title())
print(things)
print(things[0].upper())
print(things)
del(things[1])
print(things)
surprise = ['Groucho', 'Chico', 'Harpo', ]
surprise[-1].lower
surprise[-1].swapcase
surprise[-1].title()
a = [('dog','chien'), ('cat', 'chat'), ('walrus','morse')]
e2f={}
e2f=dict(a)
print(e2f)
print(e2f['walrus'])
#f2e=dict(map(lambda t:(t[1],t[0]), e2f.items()))
f2e={}
for key,val in e2f.items():
    f2e[val]=key
print(f2e)
print(f2e['chien'])
animals=['Henri','Grumpy','Lucy']
life={}
life0={'cats':animals,'octiop':"",'emus':""}
life1={}
life2={}
life={'animals':life0,'plants':life1,'others':life2}
print(life.keys())
print(life['animals'].keys())
print(life['animals']['cats'])
#20170906 4.13练习
#(1)
guess_me=7
if(guess_me<7):
    print ("too low")
if(guess_me==7):
    print ("just right")
else:
    print ("too high")
#(2)
start = 1
while (1):
    if(guess_me==start):
        print ("found it")
        break ;
    if(start<guess_me):
        print ("too low")
    if(start>guess_me):
        print ("opps")
        break ;
    start+=1
#(3)
a=[3,2,1,0]
for i in range(4):
    print(a[i])
#(4)(5)
b=[n for n in range(10) if n % 2==0]
squares0 = [(n * n) for n in range(10)]
squares1 = [n for n in range(10)]
for i in range(10):
    print(squares0[i])
print(b)
squares = {key: squares1 for squares1, key in enumerate(squares0)}
print(squares)
#(6)
odd = {n for n in range(10) if n % 2 == 1}
print(odd)
#(7)
#num = [random.uniform(0,9)]
print("第七题测试")
s = "got "
def mygot():
    num = random.randint(0, 9)
    print(s)
    print(num)
mygot()
get_intt = [s+str(n) for n in range(10) ]
print (get_intt)
#(8)
def returnabc():
    abc=['a','b','c']
    return abc
print(returnabc())
#(9)
def jishu(list):
    print(list)
    for i in range(10):
        if (i==3):
            print(a[i])
jishu(odd)
#(10)装饰器
def printabc():
    print("hello")
def start_end(func):
    print("start")
    func()
    return print("end")
start_end(printabc)
#(11)
